package tech.yunland.shop.domain.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.moyuer.bsf.domain.model.AbstractEntity;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by v on 17-7-3.
 */
@Entity
@Table(name = "exam")
public class Exam extends AbstractEntity {

    @JSONField(serialize = false)
    @OneToOne
    private ExamDescription examDescription;

    @Transient
    private String desid;

    @Transient
    private String description;

    @JSONField(serialize = false)
    @ManyToOne
    private Lessons lessons;

    @Transient
    private String lid;

    @Transient
    private String lname;

    @JSONField(format = "yyyy-MM-dd hh:mm:ss")
    @Column(name = "exam_time", nullable = false)
    private Date examTime;

    @JSONField(format = "yyyy-MM-dd hh:mm:ss")
    @Column(name = "start_time", nullable = false)
    private Date startTime;

    @JSONField(format = "yyyy-MM-dd hh:mm:ss")
    @Column(name = "end_time", nullable = false)
    private Date endTime;

    @JSONField(format = "yyyy-MM-dd hh:mm:ss")
    @Column(name = "create_time", nullable = false)
    private Date createTime = new Date();

    public String getLname() {
        if (this.lessons != null) {
            return lessons.getLname();
        }
        return lname;
    }

    public void setLname(String lname) {
        this.lname = lname;
    }

    public String getDesid() {
        if (this.examDescription != null) {
            return this.examDescription.getId();
        }
        return desid;
    }

    public void setDesid(String desid) {
        this.desid = desid;
    }

    public String getLid() {
        if (this.lessons != null) {
            return this.lessons.getId();
        }
        return lid;
    }

    public void setLid(String lid) {
        this.lid = lid;
    }

    public ExamDescription getExamDescription() {
        return examDescription;
    }

    public void setExamDescription(ExamDescription examDescription) {
        this.examDescription = examDescription;
    }

    public String getDescription() {
        if (this.examDescription != null) {
            return this.examDescription.getExamDescription();
        }
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Lessons getLessons() {
        return lessons;
    }

    public void setLessons(Lessons lessons) {
        this.lessons = lessons;
    }

    public Date getExamTime() {
        return examTime;
    }

    public void setExamTime(Date examTime) {
        this.examTime = examTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
}
